home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
USA Bestseller
/
USA BESTSELLER Vol 1-95 (Hepp-Computer)(1995).iso
/
e190
/
vbench.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-02-20
|
5KB
|
176 lines
#include "htimer.h" // HTimer class
#include <iostream.h> // cout streams class
#include <conio.h> // getch()
#include "vbench.h" // BenchData structures,bench functions
// VIDEO.ASM external function prototypes:
extern "C" {
void set_gmode(int); // set graphics mode
void set_tweaked(); // set 'tweaked' mode
void fillbuf(); // fill ram_buffer with random colors-non-planar
void fillbuft(); // fill ram_buffer with random colors-planar form
}
// Global timer class
HTimer timer1;
// BenchData array counts
const int shared_total = sizeof(shared_benches)/sizeof(SharedBenchData);
const int m13_total = sizeof(m13_benches)/sizeof(BenchData);
const int tw_total = sizeof(tw_benches)/sizeof(BenchData);
// BenchData timing results array
dword shared_results[shared_total][2];
dword m13_results[m13_total];
dword tw_results[tw_total];
//------------------------------------------------------------------------\\
// void bench_functions(BenchData * benches,dword * results,int count);
//
// Called by main() to time a group of mode-specific benchmark functions
// and place the timing results into an array.
//
// 'benches' is the array of BenchData structures
// 'results' is the array of benchmark timing results
// 'count' is the number of elements in both 'benches' and 'results'
//------------------------------------------------------------------------\\
void bench_functions(BenchData * benches,dword * results,int count)
{
int i;
for (i=0; i<count; i++)
{
timer1.timerOn(); // start timer
benches[i].do_bench(); // execute mode-specific function
results[i] = timer1.timerOff(); // stop timer, get elapsed time
}
}
//------------------------------------------------------------------------\\
// void bench_functions(
// SharedBenchData * benches,dword * results,int count,enum vmode v);
//
// Called by main() to time a group of benchmark functions and place
// the timing results into an array.
//
// 'benches' is the array of BenchData structures
// 'results' is the two-dimensional array of benchmark timing results
// 'count' is the number of elements in both 'benches' and 'results'
// 'v' is the video mode, 0=mode 13h,1=tweaked mode
//------------------------------------------------------------------------\\
void bench_functions(
SharedBenchData * benches,dword results[][2],int count,enum vmode v)
{
int i;
for (i=0; i<count; i++)
{
timer1.timerOn(); // start timer
benches[i].do_bench(v); // execute benchmark
results[i][v] = timer1.timerOff(); // stop timer, get elapsed time
}
}
//------------------------------------------------------------------------\\
// int main()
//------------------------------------------------------------------------\\
int main()
{
int i;
cout <<
"\t\tVBENCH 1.0\n"
"Video benchmark program. Press any key to begin benchmarks\n";
getch();
fillbuf(); // fill buffer with non-planar random colors
// Time the mode 13h benchmarks first
set_gmode(0x13); // set mode 13h
bench_functions(shared_benches,shared_results,shared_total,mode_13h);
bench_functions(m13_benches,m13_results,m13_total);
// Time the Tweaked mode benchmarks next
set_tweaked(); // set Tweaked mode
fillbuft(); // fill buffer with planar random colors
bench_functions(shared_benches,shared_results,shared_total,tweaked_mode);
bench_functions(tw_benches,tw_results,tw_total);
// Finished benchmarks!
set_gmode(3); // set text mode
// Display timing results
cout <<
" VBENCH 1.0\n"
"All benches were done moving 64,000 pixels of data to/from/between\n"
"screen, repeated 10 times. See vbench.txt for bench descriptions\n\n";
cout <<
" Benchmark results (microseconds):\n\n";
cout <<
" Benchmark || Mode 13h || Tweaked Mode\n"
"------------------------------||-----------||--------------\n";
cout.fill(' ');
for (i=0; i <shared_total; i++)
{
cout.setf(ios::left,ios::adjustfield);
cout.width(30);
cout << shared_benches[i].desc();
cout << "||";
cout.setf(ios::right,ios::adjustfield);
cout.width(10);
cout << shared_results[i][0];
cout << " ||";
cout.width(10);
cout << shared_results[i][1];
cout << endl;
}
cout << "\n"
" Mode-specific benchmark results (microseconds):\n\n";
cout <<
" Mode 13h Benchmark || Result\n"
"------------------------------||-----------\n";
for (i=0; i<m13_total; i++)
{
cout.setf(ios::left,ios::adjustfield);
cout.width(30);
cout << m13_benches[i].desc();
cout << "||";
cout.setf(ios::right,ios::adjustfield);
cout.width(10);
cout << m13_results[i];
cout << endl;
}
cout << "\n"
" Tweaked Mode Benchmark || Result\n"
"------------------------------||-----------\n";
for (i=0; i<tw_total; i++)
{
cout.setf(ios::left,ios::adjustfield);
cout.width(30);
cout << tw_benches[i].desc();
cout << "||";
cout.setf(ios::right,ios::adjustfield);
cout.width(10);
cout << tw_results[i];
cout << endl;
}
return 0;
}